<template>
  <Card style="height:800px">
    <div class="body_align">
      <div style="text-align:right">
        <Button type="primary" size="small" @click="handleSubmit">提交</Button>
        <Button type="primary" size="small" @click="handleSubmitLOAN" style="margin-left: 20px;">LOANAPPLY提交</Button>
      </div>
      <div>
        <Input style="margin-top: 15px;" size="small" type="text" v-model="loanId" placeholder="申请书编号"></Input>
        <Button style="margin-top:15px;" type="primary" size="small" @click="processSubmit">提交该流程完成</Button>
      </div>
      <div>
        <Input style="margin-top:15px;" size="small" type="text" v-model="loanId" placeholder="内容"></Input>
        <Input style="margin-top:15px;" size="small" type="text" v-model="status" placeholder="状态"></Input>
        <Input style="margin-top:15px;" size="small" type="text" v-model="originalState" placeholder="原始数据"></Input>
        <Button style="margin-top:15px;" type="primary" size="small" @click="processStateSubmit">提交测试更改coreservice状态</Button>
      </div>
    </div>
  </Card>
</template>

<script>
// import Cookies from 'js-cookie'
export default {
  data () {
    return {
      loanId: null,
      status: null,
      originalState: null
    }
  },
  methods: {
    processStateSubmit () {
      var params = {}
      params.loanId = this.loanId
      params.status = this.status
      params.oldStatus = this.originalState
      this.$ajax.post(this.$appContext.marvels_core_loanapply + 'loanApply/loan/service/testRabbitMQString', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.warning('操作成功!' + re.data.data)
        } else {
          this.$Message.warning(re.data.data)
        }
      }).catch(er => {
        this.$Message.warning('操作失败')
      })
    },
    processSubmit () {
      var params = {}
      params.loanId = this.loanId
      this.$ajax.post(this.$appContext.marvels_core_loanapply + 'approve/test_loan/service/testProcess', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.warning('操作成功!' + re.data.data)
        } else {
          this.$Message.warning(re.data.data)
        }
      }).catch(er => {
        this.$Message.warning('操作失败')
      })
    },
    handleSubmit () {
      var params = {}
      params.loanId = this.loanId
      this.$ajax.post(this.$appContext.marvels_core_approve + 'approve/test_loan/service/testloan', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.warning('操作成功!')
        } else {
          this.$Message.warning(re.data.data)
        }
      }).catch(er => {
        this.$Message.warning('操作失败')
      })
    },
    handleSubmitLOAN () {
      var params = {}
      params.loanId = this.loanId
      this.$ajax.post(this.$appContext.marvels_core_loanapply + 'loanApply/test_loan/service/testloan', params).then(re => {
        if (re.data.code === 'success') {
          this.$Message.warning('操作成功!')
        } else {
          this.$Message.warning(re.data.data)
        }
      }).catch(er => { this.$Message.warning('操作失败') })
    }
  },
  created () {
    this.$ajax = this.$util.ajax()
  }
}
</script>
<style>
.body_align {
  width: 80%;
  margin: 0px auto;
}
</style>
